package com.alex.j2se.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class ReflectAtt {
	
	private String name;
	
	private int age;
	
	public ReflectAtt(){}
	
	public ReflectAtt(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}
	
	/**
	 * 通过反射获取类的get方法
	 * @param args
	 * @throws SecurityException
	 * @throws NoSuchMethodException
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 * @throws InvocationTargetException
	 */
	public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException  {
		ReflectAtt f1 = new ReflectAtt("alex",1);
		@SuppressWarnings("all")
		Method m1 = f1.getClass().getMethod("getAge", null);
		@SuppressWarnings("all")
		Object res = m1.invoke(f1, null);
		System.out.println(res);
		
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}
}
